<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
include_once $_SERVER['DOCUMENT_ROOT']."/math-videos/configure.inc.php";
//include_once $site_path."/header.php";
echo $_SERVER['REQUEST_METHOD']."ttttttttt<br>";
exit();
$username="janes";
$password= "janes";
$username="ima";
$password= "ima2013";
$assetID=0;
if(isset($_REQUEST['assetID'])&&$_REQUEST['assetID']!="")
{
  $assetID=$_REQUEST['assetID'];
}
//insert
//get image 
$link='http://huarenads.com/images/listings/3_thumb.jpg';
//$link='http://huarenads.com/default.php';
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_POST, 0);
 
curl_setopt($ch,CURLOPT_URL,$link);
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
$image=curl_exec($ch);
 
curl_close($ch);
//echo $image."<br>";
//image =file_get_contents('http://huarenads.com/images/listings/3_thumb.jpg');
//$image = base64_encode($image);
$image = strtr(base64_encode(addslashes(gzcompress(serialize($image),9))), '+/=', '-_,');
//$image = urlencode(base64_encode(addslashes(gzcompress(serialize($image),9))));
/*$image = json_encode($image);
$image = json_decode($image);
$thumbnail_image_file = "2/83/3_thumb.jpg";
	$savefile = fopen($_SERVER['DOCUMENT_ROOT']."/math-videos/images/$thumbnail_image_file", 'wb');			
	fwrite($savefile, $image);
			fclose($savefile);
			//echo "<img src='".$site_http."images/2/83/3_thumb.jpg' >";	
	$content=	file_get_contents($site_http."images/2/83/3_thumb.jpg");
echo '<img src="data:image/jpg;base64,'.$content.'" />';*/
//echo $image;

/******************************************/
//if(isset($_REQUEST['mode'])&&$_REQUEST['mode']=="thumbnail_edit")
//{
  $data =  array(
					"username" =>$username,
				"password" =>$password,
				"thumbnail" => array("image" => $image,"type"=>"jpg"),
				"assetID" =>"44"
			  );   
				
  $data_string = "json=".json_encode($data); 
//	$data_string= urlencode($data_string);
	echo "<div><b>How to call the api</b>:<br>".$site_http."api/test_thumbnail.php?".$data_string."</div><br><b>Response</b>:<br>";
  $ch = curl_init($site_http.'api/test_thumbnail.php');   
//}
/*************************/
//if(isset($_REQUEST['mode'])&&$_REQUEST['mode']!="")
//{
  // Configuring curl options

  $options = array(
  CURLOPT_POST => 1,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POSTFIELDS => $data_string
); 
// Setting curl options
curl_setopt_array( $ch, $options ); 
//curl_setopt($ch, CURLOPT_POST, 1);                                                                
//curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);          
 
$result = curl_exec($ch);
curl_close($ch);
echo $result;


db_close($conn);
?>